<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QScrollBar Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QScrollBar Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QScrollBar widget provides a vertical or horizontal scroll
bar. <a href="#details">More...</a></p>

<p>Inherits <a href="qabstractslider.html">QAbstractSlider</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qscrollbar.html#QScrollBar">__init__</a></b> (<i>self</i>, QWidget&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qscrollbar.html#QScrollBar-2">__init__</a></b> (<i>self</i>, Qt.Orientation&#160;<i>orientation</i>, QWidget&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qscrollbar.html#contextMenuEvent">contextMenuEvent</a></b> (<i>self</i>, QContextMenuEvent)</li><li><div class="fn" />bool <b><a href="qscrollbar.html#event">event</a></b> (<i>self</i>, QEvent&#160;<i>event</i>)</li><li><div class="fn" /><b><a href="qscrollbar.html#hideEvent">hideEvent</a></b> (<i>self</i>, QHideEvent)</li><li><div class="fn" /><b><a href="qscrollbar.html#initStyleOption">initStyleOption</a></b> (<i>self</i>, QStyleOptionSlider&#160;<i>option</i>)</li><li><div class="fn" /><b><a href="qscrollbar.html#mouseMoveEvent">mouseMoveEvent</a></b> (<i>self</i>, QMouseEvent)</li><li><div class="fn" /><b><a href="qscrollbar.html#mousePressEvent">mousePressEvent</a></b> (<i>self</i>, QMouseEvent)</li><li><div class="fn" /><b><a href="qscrollbar.html#mouseReleaseEvent">mouseReleaseEvent</a></b> (<i>self</i>, QMouseEvent)</li><li><div class="fn" /><b><a href="qscrollbar.html#paintEvent">paintEvent</a></b> (<i>self</i>, QPaintEvent)</li><li><div class="fn" />QSize <b><a href="qscrollbar.html#sizeHint">sizeHint</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qscrollbar.html#sliderChange">sliderChange</a></b> (<i>self</i>, QAbstractSlider.SliderChange&#160;<i>change</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QScrollBar widget provides a vertical or horizontal scroll
bar.</p>
<p>A scroll bar is a control that enables the user to access parts
of a document that is larger than the widget used to display it. It
provides a visual indication of the user's current position within
the document and the amount of the document that is visible. Scroll
bars are usually equipped with other controls that enable more
accurate navigation. Qt displays scroll bars in a way that is
appropriate for each platform.</p>
<p>If you need to provide a scrolling view onto another widget, it
may be more convenient to use the <a href="qscrollarea.html">QScrollArea</a> class because this provides a
viewport widget and scroll bars. QScrollBar is useful if you need
to implement similar functionality for specialized widgets using
<a href="qabstractscrollarea.html">QAbstractScrollArea</a>; for
example, if you decide to subclass <a href="qabstractitemview.html">QAbstractItemView</a>. For most other
situations where a slider control is used to obtain a value within
a given range, the <a href="qslider.html">QSlider</a> class may be
more appropriate for your needs.</p>
<table class="generic">
<tr class="odd" valign="top">
<td>
<p class="centerAlign"><img alt="" src="images/qscrollbar-picture.png" /></p>
</td>
<td>Scroll bars typically include four separate controls: a slider,
scroll arrows, and a page control.
<ul>
<li>a. The slider provides a way to quickly go to any part of the
document, but does not support accurate navigation within large
documents.</li>
<li>b. The scroll arrows are push buttons which can be used to
accurately navigate to a particular place in a document. For a
vertical scroll bar connected to a text editor, these typically
move the current position one "line" up or down, and adjust the
position of the slider by a small amount. In editors and list boxes
a "line" might mean one line of text; in an image viewer it might
mean 20 pixels.</li>
<li>c. The page control is the area over which the slider is
dragged (the scroll bar's background). Clicking here moves the
scroll bar towards the click by one "page". This value is usually
the same as the length of the slider.</li>
</ul>
</td>
</tr>
</table>
<p>Each scroll bar has a value that indicates how far the slider is
from the start of the scroll bar; this is obtained with <a href="qabstractslider.html#value-prop">value</a>() and set with <a href="qabstractslider.html#value-prop">setValue</a>(). This value always
lies within the range of values defined for the scroll bar, from
<a href="qabstractslider.html#minimum-prop">minimum()</a> to
<a href="qabstractslider.html#minimum-prop">maximum()</a>
inclusive. The range of acceptable values can be set with <a href="qabstractslider.html#minimum-prop">setMinimum</a>() and <a href="qabstractslider.html#maximum-prop">setMaximum</a>(). At the
minimum value, the top edge of the slider (for a vertical scroll
bar) or left edge (for a horizontal scroll bar) will be at the top
(or left) end of the scroll bar. At the maximum value, the bottom
(or right) edge of the slider will be at the bottom (or right) end
of the scroll bar.</p>
<p>The length of the slider is usually related to the value of the
page step, and typically represents the proportion of the document
area shown in a scrolling view. The page step is the amount that
the value changes by when the user presses the <b>Page Up</b> and
<b>Page Down</b> keys, and is set with <a href="qabstractslider.html#pageStep-prop">setPageStep</a>(). Smaller
changes to the value defined by the line step are made using the
cursor keys, and this quantity is set with <a href="qabstractslider.html#singleStep-prop">setSingleStep()</a>.</p>
<p>Note that the range of values used is independent of the actual
size of the scroll bar widget. You do not need to take this into
account when you choose values for the range and the page step.</p>
<p>The range of values specified for the scroll bar are often
determined differently to those for a <a href="qslider.html">QSlider</a> because the length of the slider needs
to be taken into account. If we have a document with 100 lines, and
we can only show 20 lines in a widget, we may wish to construct a
scroll bar with a page step of 20, a minimum value of 0, and a
maximum value of 80. This would give us a scroll bar with five
"pages".</p>
<table class="generic">
<tr class="odd" valign="top">
<td><img alt="" src="images/qscrollbar-values.png" /></td>
<td>The relationship between a document length, the range of values
used in a scroll bar, and the page step is simple in many common
situations. The scroll bar's range of values is determined by
subtracting a chosen page step from some value representing the
length of the document. In such cases, the following equation is
useful: <i>document length</i> = <a href="qabstractslider.html#maximum-prop">maximum</a>() - <a href="qabstractslider.html#minimum-prop">minimum</a>() + <a href="qabstractslider.html#pageStep-prop">pageStep</a>().</td>
</tr>
</table>
<p>QScrollBar only provides integer ranges. Note that although
QScrollBar handles very large numbers, scroll bars on current
screens cannot usefully represent ranges above about 100,000
pixels. Beyond that, it becomes difficult for the user to control
the slider using either the keyboard or the mouse, and the scroll
arrows will have limited use.</p>
<p>ScrollBar inherits a comprehensive set of signals from <a href="qabstractslider.html">QAbstractSlider</a>:</p>
<ul>
<li><a href="qabstractslider.html#valueChanged">valueChanged()</a>
is emitted when the scroll bar's value has changed. The tracking()
determines whether this signal is emitted during user
interaction.</li>
<li><a href="qabstractslider.html#rangeChanged">rangeChanged()</a>
is emitted when the scroll bar's range of values has changed.</li>
<li><a href="qabstractslider.html#sliderPressed">sliderPressed()</a> is emitted
when the user starts to drag the slider.</li>
<li><a href="qabstractslider.html#sliderMoved">sliderMoved()</a> is
emitted when the user drags the slider.</li>
<li><a href="qabstractslider.html#sliderReleased">sliderReleased()</a> is
emitted when the user releases the slider.</li>
<li><a href="qabstractslider.html#actionTriggered">actionTriggered()</a> is
emitted when the scroll bar is changed by user interaction or via
the <a href="qabstractslider.html#triggerAction">triggerAction()</a>
function.</li>
</ul>
<p>A scroll bar can be controlled by the keyboard, but it has a
default <a href="qwidget.html#focusPolicy-prop">focusPolicy</a>()
of <a href="qt.html#FocusPolicy-enum">Qt.NoFocus</a>. Use <a href="qwidget.html#focusPolicy-prop">setFocusPolicy</a>() to enable
keyboard interaction with the scroll bar:</p>
<ul>
<li>Left/Right move a horizontal scroll bar by one single
step.</li>
<li>Up/Down move a vertical scroll bar by one single step.</li>
<li>PageUp moves up one page.</li>
<li>PageDown moves down one page.</li>
<li>Home moves to the start (mininum).</li>
<li>End moves to the end (maximum).</li>
</ul>
<p>The slider itself can be controlled by using the <a href="qabstractslider.html#triggerAction">triggerAction()</a> function
to simulate user interaction with the scroll bar controls. This is
useful if you have many different widgets that use a common range
of values.</p>
<p>Most GUI styles use the <a href="qabstractslider.html#pageStep-prop">pageStep</a>() value to
calculate the size of the slider.</p>
<table class="generic" width="100%">
<tr class="odd" valign="top">
<td><img alt="Screenshot of a Macintosh style scroll bar" src="images/macintosh-horizontalscrollbar.png" /></td>
<td>A scroll bar shown in the <a href="gallery-macintosh.html">Macintosh widget style</a>.</td>
</tr>
<tr class="even" valign="top">
<td><img alt="Screenshot of a Windows XP style scroll bar" src="images/windowsxp-horizontalscrollbar.png" /></td>
<td>A scroll bar shown in the <a href="gallery-windowsxp.html">Windows XP widget style</a>.</td>
</tr>
<tr class="odd" valign="top">
<td><img alt="Screenshot of a Plastique style scroll bar" src="images/plastique-horizontalscrollbar.png" /></td>
<td>A scroll bar shown in the <a href="gallery-plastique.html">Plastique widget style</a>.</td>
</tr>
</table>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QScrollBar" />QScrollBar.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a vertical scroll bar.</p>
<p>The <i>parent</i> argument is sent to the <a href="qwidget.html">QWidget</a> constructor.</p>
<p>The <a href="qabstractslider.html#minimum-prop">minimum</a>
defaults to 0, the <a href="qabstractslider.html#maximum-prop">maximum</a> to 99, with a
<a href="qabstractslider.html#singleStep-prop">singleStep</a> size
of 1 and a <a href="qabstractslider.html#pageStep-prop">pageStep</a> size of 10, and
an initial <a href="qabstractslider.html#value-prop">value</a> of
0.</p>


<h3 class="fn"><a name="QScrollBar-2" />QScrollBar.__init__ (<i>self</i>, <a href="qt.html#Orientation-enum">Qt.Orientation</a>&#160;<i>orientation</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a scroll bar with the given <i>orientation</i>.</p>
<p>The <i>parent</i> argument is passed to the <a href="qwidget.html">QWidget</a> constructor.</p>
<p>The <a href="qabstractslider.html#minimum-prop">minimum</a>
defaults to 0, the <a href="qabstractslider.html#maximum-prop">maximum</a> to 99, with a
<a href="qabstractslider.html#singleStep-prop">singleStep</a> size
of 1 and a <a href="qabstractslider.html#pageStep-prop">pageStep</a> size of 10, and
an initial <a href="qabstractslider.html#value-prop">value</a> of
0.</p>


<h3 class="fn"><a name="contextMenuEvent" />QScrollBar.contextMenuEvent (<i>self</i>, <a href="qcontextmenuevent.html">QContextMenuEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#contextMenuEvent">QWidget.contextMenuEvent</a>().</p>


<h3 class="fn"><a name="event" />bool QScrollBar.event (<i>self</i>, <a href="qevent.html">QEvent</a>&#160;<i>event</i>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p>


<h3 class="fn"><a name="hideEvent" />QScrollBar.hideEvent (<i>self</i>, <a href="qhideevent.html">QHideEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#hideEvent">QWidget.hideEvent</a>().</p>


<h3 class="fn"><a name="initStyleOption" />QScrollBar.initStyleOption (<i>self</i>, <a href="qstyleoptionslider.html">QStyleOptionSlider</a>&#160;<i>option</i>)</h3><p>Initialize <i>option</i> with the values from this <a href="qscrollbar.html">QScrollBar</a>. This method is useful for
subclasses when they need a <a href="qstyleoptionslider.html">QStyleOptionSlider</a>, but don't want to
fill in all the information themselves.</p>
<p><b>See also</b> <a href="qstyleoption.html#initFrom">QStyleOption.initFrom</a>().</p>


<h3 class="fn"><a name="mouseMoveEvent" />QScrollBar.mouseMoveEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#mouseMoveEvent">QWidget.mouseMoveEvent</a>().</p>


<h3 class="fn"><a name="mousePressEvent" />QScrollBar.mousePressEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#mousePressEvent">QWidget.mousePressEvent</a>().</p>


<h3 class="fn"><a name="mouseReleaseEvent" />QScrollBar.mouseReleaseEvent (<i>self</i>, <a href="qmouseevent.html">QMouseEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#mouseReleaseEvent">QWidget.mouseReleaseEvent</a>().</p>


<h3 class="fn"><a name="paintEvent" />QScrollBar.paintEvent (<i>self</i>, <a href="qpaintevent.html">QPaintEvent</a>)</h3><p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget.paintEvent</a>().</p>


<h3 class="fn"><a name="sizeHint" /><a href="qsize.html">QSize</a> QScrollBar.sizeHint (<i>self</i>)</h3><p>Reimplemented from <a href="qwidget.html#sizeHint-prop">QWidget.sizeHint</a>().</p>


<h3 class="fn"><a name="sliderChange" />QScrollBar.sliderChange (<i>self</i>, <a href="qabstractslider.html#SliderChange-enum">QAbstractSlider.SliderChange</a>&#160;<i>change</i>)</h3><p>Reimplemented from <a href="qabstractslider.html#sliderChange">QAbstractSlider.sliderChange</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>